//
//  BaseNavViewController.swift
//  Weibo
//
//  Created by 明丽 on 16/1/20.
//  Copyright © 2016年 明丽. All rights reserved.
//

import UIKit

class BaseNavViewController: UINavigationController,UIGestureRecognizerDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()
        //重新设置右手滑动的手势代理
        self.interactivePopGestureRecognizer?.delegate = self
        
    }
    
    
    
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        if childViewControllers.count != 0 {
        
        viewController.hidesBottomBarWhenPushed = true
        let btn = UIButton(title: "返回", fontSize: 14, color: UIColor.darkGrayColor(), backImageName: nil, imageName: "navigationbar_back_withtext")
        btn.addTarget(self, action: "back", forControlEvents: .TouchUpInside)
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: btn)
            
            
        }
        
        super.pushViewController(viewController, animated: animated)
    }
    @objc private func back() {
        popViewControllerAnimated(true)
    }
    
    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        print("OK")
        
        
        return childViewControllers.count > 1
    }
    
    

}
